var to; // variable to which we assign setTimeout function
//    var prm = Sys.WebForms.PageRequestManager.getInstance(); // Page Request Manager object


function onTxtKeyUp(elem) {
    to = setTimeout('performSearch("' + elem.id + '");', 300);
}
function onTxtKeyDown() {
    if (to) clearTimeout(to);
}
function performSearch(elemid) {

    __doPostBack(elemid, 'Change');
}

function HidePanel(elemid) {
    var pan = document.getElementById(elemid);
    pan.style.display = "none";

}

function selectItem(elemid, gui) {
    __doPostBack(elemid, 'Click');
}

function PositionList(poselem, elemid) {
    var elem = $get(elemid);
    var pos = $get(poselem);
    if (elem != null) {
        elem.style.left = findPosX(pos);
        elem.style.top = findPosY(pos) + 20;
    }

}
function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent)
        while (1) {
            curleft += obj.offsetLeft;
            if (!obj.offsetParent)
                break;
            obj = obj.offsetParent;
        }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}

function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent)
        while (1) {
            curtop += obj.offsetTop;
            if (!obj.offsetParent)
                break;
            obj = obj.offsetParent;
        }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}
function OnScroll(id) {

    var elem = document.getElementById(id);
    elem.style.position = "relative";
    elem.style.posTop = elem.parentNode.scrollTop + 10;
    window.status = elem.style.posTop;

}
function OnClose(elem) {
    elem.parentNode.style.display = 'none';
}